// Sokoban levels based on those in the Nethack game
// (http://www.nethack.org).

var sokobanLevels = [
  {field: ["##############",
           "#    #  #    #",
           "# 0  ####    #",
           "#  @         #",
           "#  #######   #",
           "####   ### ###",
           "       #     #",
           "       #0    #",
           "       #     #",
           "      ##     #",
           "      #*0 0  #",
           "      ########"],
   boulders: 5},
  
  {field: ["###########   ",
           "#    #    #   ",
           "#  00#00 @#   ",
           "#     0   #   ",
           "#    #    #   ",
           "## #########  ",
           "#  0 #     #  ",
           "# 00 #0 0 0#  ",
           "#  0     0 #  ",
           "# 000#0  0 ###",
           "#    #  0 0 *#",
           "##############"],
   boulders: 20},
                                         
  {field: ["##########    ",
           "#@      *#    ",
           "#       ##    ",
           "####### ######",
           " #           #",
           " # 0 0 0 0 0 #",
           "######## #####",
           "#   0 0  0 0 #",
           "#   0        #",
           "##### ########",
           " #  0 0 0   # ",
           " #     0    # ",
           " # 0 0   0 ## ",
           "####### ####  ",
           "#  0     #    ",
           "#        #    ",
           "#   ######    ",
           "#####         "],
   boulders: 16},

  {field: [" ####         ",
           "## @########  ",
           "#          #  ",
           "# 0#####0# #  ",
           "#  #   # 0 #  ",
           "# 0 0    0##  ",
           "# 0  0  #  #  ",
           "# ####0 ## #  ",
           "#  0   0 # ## ",
           "# ###0#   0 ##",
           "#   #  0# 0 *#",
           "#  0      ####",
           "#####  #  #   ",
           "    #######   "],
   boulders: 12},

  {field: ["######    #####",
           "#  #*##  ##   #",
           "#     #### 0  #",
           "# 00  #  #  0 #",
           "##  00#   00 ##",
           " #0  0   #0  # ",
           " # 00 #  #  0# ",
           " # 0 0#### 0 # ",
           " #       #  ## ",
           " #### 0  # ##  ",
           "    ### ## #   ",
           "     # 0   #   ",
           "     #@ #  #   ",
           "     #######   "],
   boulders: 18},
   
   {field: [
   			"##############",
            "#@           #",		
            "# 0     0    #",
            "# 0  *     0 #",
            "#            #",
            "#   0    0   #",
            "#      ##    #",
            "##############"
           ],
   boulders: 6},
   ];

   
//for(var index=5;index<sokobanLevels.length;index++){
//	(sokobanLevels[index]).boulders=countRocks((sokobanLevels[index]).field);
//}  

function Point(x, y) {
  this.x = x;
  this.y = y;
}
Point.prototype.add = function(other) {
  return new Point(this.x + other.x, this.y + other.y);
};
Point.prototype.isEqualTo = function(other) {
  return this.x == other.x && this.y == other.y;
};

var arrowKeyCodes = new Dictionary({
  37: new Point(-1, 0), // left
  38: new Point(0, -1), // up
  39: new Point(1, 0),  // right
  40: new Point(0, 1)   // down
});